package com.jinxin.platform.cdflowchart.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jinxin.platform.cdflowchart.mapper.CdflowchartValueMapper;
import com.jinxin.platform.cdflowchart.pojo.domains.CdflowchartValue;
import com.jinxin.platform.cdflowchart.service.CdflowchartValueService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CdflowchartValue)表服务实现类
 *
 * @author cyl
 * @since 2021-10-12 10:59:12
 */
@Service("cdflowchartValueService")
public class CdflowchartValueServiceImpl implements CdflowchartValueService {
    @Resource
    private CdflowchartValueMapper cdflowchartValueMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CdflowchartValue queryById(String id) {
        return this.cdflowchartValueMapper.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public PageInfo<CdflowchartValue> queryAllByLimit(int offset, int limit, CdflowchartValue cdflowchartValue) {
        PageHelper.startPage(offset, limit);
        PageInfo<CdflowchartValue> pageInfo = new PageInfo<>(cdflowchartValueMapper.queryAll(cdflowchartValue));
        return pageInfo;
    }

    /**
     * 新增数据
     *
     * @param cdflowchartValue 实例对象
     * @return 实例对象
     */
    @Override
    public CdflowchartValue insert(CdflowchartValue cdflowchartValue) {
        this.cdflowchartValueMapper.insert(cdflowchartValue);
        return cdflowchartValue;
    }

    @Override
    public int insertBatch(List<CdflowchartValue> list) {
        return this.cdflowchartValueMapper.insertBatch(list);
    }

    /**
     * 修改数据
     *
     * @param cdflowchartValue 实例对象
     * @return 实例对象
     */
    @Override
    public CdflowchartValue update(CdflowchartValue cdflowchartValue) {
        this.cdflowchartValueMapper.update(cdflowchartValue);
        return this.queryById(cdflowchartValue.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.cdflowchartValueMapper.deleteById(id) > 0;
    }


    /**
     * 根据对象查找数据
     *
     * @param cdflowchartValue 实例对象
     * @return 实例对象
     */
    @Override
    public List<CdflowchartValue> queryAll(CdflowchartValue cdflowchartValue) {

        return this.cdflowchartValueMapper.queryAll(cdflowchartValue);
    }
}